<template>
    <div class="nav">
        <div class="bx">
            <div class="left">
                <div v-for="(v,index) in navArr" :key="index" @click="funNav(index)" :class="{fontStyle:current==index}">
                    {{ v }}
                    <div class="line" v-show="current==index"></div>
                </div>
            </div>
            <div class="right" @click="funSearch">
                <img src="https://gw.alicdn.com/tfs/TB1xECwcBKw3KVjSZFOXXarDVXa-52-52.png_110x10000.jpg_.webp" alt="">
                <span>{{ seaArr[seaIndex] }}</span>
            </div>
        </div>
        <div class="bottomList">
            <List v-for="(v, index) in arr" :key="index" :img1="v.img1" :proname="v.proname" :originprice="v.originprice" :sales="v.sales" :flag="true" @click.native="goDetail1(v)"></List>
        </div>
    </div>
</template>

<script>
import List from '@/components/xn/HomeCom/Goods/List.vue'


export default {
    name:"hotBody",
    data(){
        return {
            navArr:["特价好货","9.9包邮","食品生鲜","百货","女装","家电"],
            current:0,
            seaArr:["挂钩","保鲜袋","花盆","发箍","手机壳"],
            seaIndex:0,
            arr:[]
        }
    },
    methods:{
        funNav(index){
            this.current = index
            this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:index+1
            }
        }).then(res=>{
            this.arr = res.data.data
        })
        },
        swiper(){
            setInterval(()=>{
                this.seaIndex++
                if(this.seaIndex == this.seaArr.length) {
                    this.seaIndex = 0
                }
            },2000)
        },
        goDetail1(v) {
         this.$router.push({
            path: '/detail',
            query: {
               delList: JSON.stringify(v)
            }
         })
        },
        funSearch(){
            this.$router.push("/mysearch").catch(err=>{})
        }
    },
    mounted(){
        this.swiper()
        this.$http({
            url:`http://118.178.238.19:3001/api/pro/recommendlist`,
            method:"get",
            params:{
                count:this.current+1
            }
        }).then(res=>{
            this.arr = res.data.data
            console.log(res.data.data)
        })
    },
    components:{
        List
    }
}
</script>

<style lang="scss" scoped>
    .nav {
        width: 100%;
        height: 0.89rem;
    }
    .nav .bx {
        width: 7.19rem;
        height: 100%;
        margin: auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
    } 
    .nav .bx .left {
        width: 5.43rem;
        height: 0.89rem;
        display: flex;
        overflow: auto;
        align-items: center;
    }
    .nav .bx .left>div {
        height: 0.52rem;
        font-size: 0.32rem;
        color: #282828;
        flex-shrink: 0;
        margin-right: 0.4rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center
    }
    .nav .bx .left .fontStyle {
        color: #ff5000;
        font-size: 0.32rem;
        font-weight: bold;
    }
    .nav .bx .left>div .line {
        width: 0.67rem;
        height: 0.08rem;
        background: #ff5000;
    }
    .nav .bx .right {
        width: 1.56rem;
        height: 0.51rem;
        box-sizing: border-box;
        border-radius: 0.24rem;
        border: 0.03rem solid #ff7a3d;
        display: flex;
        justify-content: center;
        align-items: center;
        color: #999999;
        font-size: 0.26rem;
    }
    .nav .bx .right img {
        width: 0.3rem;
        height: 0.3rem;
        margin-right: 0.19rem;
    }
    .nav .bottomList {
        width: 7.27rem;
        margin: auto;
        column-count: 2;
    }
</style>